import 'package:dio/dio.dart';
import 'package:flutter/material.dart';

class DioCase extends StatelessWidget {
  const DioCase({super.key});
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          GestureDetector(
            onTap: () async {
              final dio = Dio();
              final response = await dio.get('https://geek.itheima.net/v1_0/channels');
              print(response.data['data']['channels']);
            },
            child: const Text('网络请求'),
          ),
          ElevatedButton(
            onPressed: () async {
              final dio = Dio();
              var response = await dio.get('https://geek.itheima.net/v1_0/channels',
              );
              print(response.data['data']['channels']);
            },
            child: const Text('发送网络请求'),
          ),
          TextButton(
            onPressed: () async {
              final dio = Dio();
              var response = await dio.get('https://geek.itheima.net/v1_0/channels',
              );
              print(response.data['data']['channels']);
            },
           child: const Text('发送网络请求'))
        ],
      ),
    );
  }
}